

<div class="layui-form" lay-filter="layuiadmin-form-teacher" style="padding: 20px 30px 0 0;">
  <div class="layui-form-item">
    <label class="layui-form-label">所属部门</label>
    <div class="layui-input-inline">
      <script type="text/html" template>
        <input type="text" name="pidh" id="pidh" value="{{ d.params.departmentId || '' }}" />
        <select name="pdnames" id="pdnames">
          <option value="" selected>请选择所属部门</option>
        </select>
      </script>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">教师姓名</label>
    <div class="layui-input-inline">
      <script type="text/html" template>
        <input type="text" name="cname" value="{{ d.params.teacherName || '' }}" lay-verify="required" placeholder="请输入教师姓名" autocomplete="off" class="layui-input">
        <input type="hidden" name="cid" value="{{ d.params.teacherId || '' }}"  autocomplete="off" class="layui-input">
      </script>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">教师编号</label>
    <div class="layui-input-inline">
      <script type="text/html" template>
        <input type="text" name="tnum" value="{{ d.params.teacherNum || '' }}" lay-verify="required" placeholder="请输入教师编号" autocomplete="off" class="layui-input">
      </script>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">联系电话</label>
    <div class="layui-input-inline">
      <script type="text/html" template>
        <input type="text" name="tphone" value="{{ d.params.teacherPhone || '' }}" placeholder="请输入联系电话" autocomplete="off" class="layui-input">
      </script>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">性别</label>
    <div class="layui-input-inline">
      <script type="text/html" template>
        <select name="tgender" id="tgender">
          <option value="" selected>请选择性别</option>
          <option value="男" {{ d.params.teacherGender === '男' ? 'selected' : '' }}>男</option>
          <option value="女" {{ d.params.teacherGender === '女' ? 'selected' : '' }}>女</option>
        </select>
      </script>
    </div>
  </div>
  <div class="layui-form-item" lay-filter="cflag">
    <label class="layui-form-label">状态</label>
    <div class="layui-input-inline">
      <script type="text/html" template>
        <input type="radio" name="cflag" value="0" title="启用" {{ d.params.teacherFlag === '启用' ? 'checked' : '' }} checked>
        <input type="radio" name="cflag" value="1" title="禁用" {{ d.params.teacherFlag === '禁用' ? 'checked' : '' }}>
      </script>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label"></label>
    <div class="layui-input-inline">
      <input type="button" lay-submit lay-filter="LAY-teacher-add" value="确认" class="layui-btn">
    </div>
  </div>
</div>

<script>
layui.use(['admin', 'form'], function(){
  var $ = layui.$
  ,form = layui.form;

});
/* layui.data.sendParams = function(params){
    console.log(params);    //得到传递过来的参数
}); */
layui.use([ 'form', 'layer' ], function() {
  $ = layui.$;
  var form = layui.form, layer = layui.layer;

  //加载所属部门下拉列表
  $.ajax({
    url : '/getDeptsServlet',
    dataType : 'json',
    type : 'post',
    timeout : 10000,
    success : function(data) {
      $.each(data.data, function(index, value) {
        $('#pdnames').append(
                new Option(value.departmentName, value.departmentId)
        );
      });
      form.render("select");
    }
  });
	/* //加载外键2
	$.ajax({
		url : '/ChinapartyProject/getDeptsServlet',
		dataType : 'json', //服务器返回json格式数据
		type : 'post', //HTTP请求类型
		timeout : 10000, //超时时间设置为10秒；
		success : function(data) {
			$.each(data.data, function(index, value) {
				$('#pdnames').append(
						new Option(value.teacherName, value.teacherid));// 下拉菜单里添加元素
			});
			form.render("select");
		}
	}); */
});
</script>